package com.gitee.client;

import com.gitee.enums.ResponseEnum;
import com.gitee.exception.CookbookException;
import com.gitee.exception.UserException;
import com.gitee.sdk.CookbookSDK;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;

@FeignClient(name = "canteen-wx-cookbook", fallback = CookbookClient.CookbookClientFallBack.class)
public interface CookbookClient {

    @GetMapping("/client/cookbook/today")
    CookbookSDK getTodayCookbook(Integer cookbookType);

    @Component
    static class CookbookClientFallBack implements CookbookClient {
        @Override
        public CookbookSDK getTodayCookbook(Integer cookbookType) {
            throw new CookbookException(ResponseEnum.ERROR);
        }
    }
}
